package ms.shop.dao;

import mapper.MsMapper;
import ms.shop.entity.Attr;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface AttrDAO extends MsMapper<Attr> {

    /**
     * 属性列表
     * @return
     */
    @Select("<script>"
            + "select * from t_attr "
            + "where 1=1 "
            + "order by create_time desc" + "</script>")
    @ResultType(Attr.class)
    List<Attr> queryAttrs();

    /**
     * 属性列表
     * @return
     */
    @Select("<script>"
            + "select * from t_attr "
            + "where 1=1 "
            + "<if test=\"classifyId != null and  classifyId!= 0 \"> and classify_id=#{classifyId} </if> "
            + "order by create_time desc" + "</script>")
    @ResultType(Attr.class)
    List<Attr> queryAttrList(@Param("classifyId") Long classifyId);
}
